//
//  PopularForecastFromModel_Two.m
//  Gxj
//
//  Created by 刘伟 on 2017/10/13.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "PopularForecastFromModel_Two.h"

NSString *const kPopularForecastTwoMeetingid    = @"meetingid";
NSString *const kPopularForecastTwoTitle        = @"title";
NSString *const kPopularForecastTwoInfo         = @"info";
NSString *const kPopularForecastTwoIndustryid   = @"industryid";
NSString *const kPopularForecastTwoUserid       = @"userid";
NSString *const kPopularForecastTwoCreate_date  = @"create_date";
NSString *const kPopularForecastTwoStart_date   = @"start_date";
NSString *const kPopularForecastTwoHead_img     = @"head_img";
NSString *const kPopularForecastTwoNickname     = @"nickname";
NSString *const kPopularForecastTwoImgsrc       = @"imgsrc";
NSString *const kPopularForecastTwoPosition     = @"position";
NSString *const kPopularForecastTwoViewnum      = @"viewnum";
NSString *const kPopularForecastTwoSupportnum   = @"supportnum";
NSString *const kPopularForecastTwoFollow       = @"follow";

@implementation PopularForecastFromModel_Two

@synthesize meetingid   = _meetingid;
@synthesize title       = _title;
@synthesize info        = _info;
@synthesize industryid  = _industryid;
@synthesize userid      = _userid;
@synthesize create_date = _create_date;
@synthesize start_date  = _start_date;
@synthesize head_img    = _head_img;
@synthesize nickname    = _nickname;
@synthesize imgsrc      = _imgsrc;
@synthesize position    = _position;
@synthesize viewnum     = _viewnum;
@synthesize supportnum  = _supportnum;
@synthesize follow      = _follow;

// 处理model套model 或者array套dictionary、array
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

// 初始化
- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    if (self && [dict isKindOfClass:[NSDictionary class]])
    {
        _meetingid   = [self checkNilObjectForKey:kPopularForecastTwoMeetingid   fromDictionary:dict];
        _userid      = [self checkNilObjectForKey:kPopularForecastTwoUserid      fromDictionary:dict];
        _head_img    = [self checkNilObjectForKey:kPopularForecastTwoHead_img    fromDictionary:dict];
        _nickname    = [self checkNilObjectForKey:kPopularForecastTwoNickname    fromDictionary:dict];
        _industryid  = [self checkNilObjectForKey:kPopularForecastTwoIndustryid  fromDictionary:dict];
        _info        = [self checkNilObjectForKey:kPopularForecastTwoInfo        fromDictionary:dict];
        _imgsrc      = [self checkNilObjectForKey:kPopularForecastTwoImgsrc      fromDictionary:dict];
        _create_date = [self checkNilObjectForKey:kPopularForecastTwoCreate_date fromDictionary:dict];
        _start_date  = [self checkNilObjectForKey:kPopularForecastTwoStart_date  fromDictionary:dict];
        _position    = [self checkNilObjectForKey:kPopularForecastTwoPosition    fromDictionary:dict];
        _title       = [self checkNilObjectForKey:kPopularForecastTwoTitle       fromDictionary:dict];
        _viewnum     = [self checkNilObjectForKey:kPopularForecastTwoViewnum     fromDictionary:dict];
        _supportnum  = [self checkNilObjectForKey:kPopularForecastTwoSupportnum  fromDictionary:dict];
        _follow      = [self checkNilObjectForKey:kPopularForecastTwoFollow      fromDictionary:dict];
    }
    return self;
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:_meetingid    forKey:kPopularForecastTwoMeetingid];
    [mutableDict setValue:_userid       forKey:kPopularForecastTwoUserid];
    [mutableDict setValue:_head_img     forKey:kPopularForecastTwoHead_img];
    [mutableDict setValue:_nickname     forKey:kPopularForecastTwoNickname];
    [mutableDict setValue:_industryid   forKey:kPopularForecastTwoIndustryid];
    [mutableDict setValue:_info         forKey:kPopularForecastTwoInfo];
    [mutableDict setValue:_imgsrc       forKey:kPopularForecastTwoImgsrc];
    [mutableDict setValue:_create_date  forKey:kPopularForecastTwoCreate_date];
    [mutableDict setValue:_start_date   forKey:kPopularForecastTwoStart_date];
    [mutableDict setValue:_position     forKey:kPopularForecastTwoPosition];
    [mutableDict setValue:_title        forKey:kPopularForecastTwoTitle];
    [mutableDict setValue:_viewnum      forKey:kPopularForecastTwoViewnum];
    [mutableDict setValue:_supportnum   forKey:kPopularForecastTwoSupportnum];
    [mutableDict setValue:_follow       forKey:kPopularForecastTwoFollow];
    
    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (id)checkNilObjectForKey:(id)key fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:key];
    return [object isKindOfClass:[NSNull class]] ? nil : object;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"%@",[self dictionaryRepresentation]];
}

@end
